<html>
<head><meta charset="utf-8"><title>Auto-updating ambiguous references? · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Auto-updating.20ambiguous.20references.3F.html">Auto-updating ambiguous references?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="242009810"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Auto-updating%20ambiguous%20references%3F/near/242009810" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Teddy Katz <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Auto-updating.20ambiguous.20references.3F.html#242009810">(Jun 09 2021 at 01:55)</a>:</h4>
<p>Has there been any work in rustup and/or cargo on auto-updating code when a library changes and causes it to be ambiguous? E.g. if upgrading a library dependency would lead to a name collision with method call syntax due to a new trait impl, <code>cargo update</code> could resolve the ambiguity based on how the code compiled beforehand, and then automatically update the code to use UFCS to match.</p>



<a name="242009927"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Auto-updating%20ambiguous%20references%3F/near/242009927" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Auto-updating.20ambiguous.20references.3F.html#242009927">(Jun 09 2021 at 01:57)</a>:</h4>
<p>cargo update seems like the wrong command for that, cargo fix is a better place</p>



<a name="242009934"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Auto-updating%20ambiguous%20references%3F/near/242009934" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Auto-updating.20ambiguous.20references.3F.html#242009934">(Jun 09 2021 at 01:57)</a>:</h4>
<p>I would be very surprised and a little upset if cargo update modified my code</p>



<a name="242009958"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Auto-updating%20ambiguous%20references%3F/near/242009958" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Teddy Katz <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Auto-updating.20ambiguous.20references.3F.html#242009958">(Jun 09 2021 at 01:58)</a>:</h4>
<p>It seems like the problem with cargo fix would be that by the time it gets run, the dependencies have already been upgraded and the information about how to resolve ambiguities would be lost.</p>



<a name="242026850"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Auto-updating%20ambiguous%20references%3F/near/242026850" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> The 8472 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Auto-updating.20ambiguous.20references.3F.html#242026850">(Jun 09 2021 at 07:37)</a>:</h4>
<p>check if the repo has source control, get cargo.toml/lock from the latest committed version to get information needed?</p>



<a name="242040061"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Auto-updating%20ambiguous%20references%3F/near/242040061" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Auto-updating.20ambiguous.20references.3F.html#242040061">(Jun 09 2021 at 09:47)</a>:</h4>
<p>cargo update --fix seems ok</p>



<a name="242040082"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Auto-updating%20ambiguous%20references%3F/near/242040082" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Auto-updating.20ambiguous.20references.3F.html#242040082">(Jun 09 2021 at 09:47)</a>:</h4>
<p>But I really don't think it should be on by default, it's too surprising</p>



<a name="242045096"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Auto-updating%20ambiguous%20references%3F/near/242045096" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> The 8472 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Auto-updating.20ambiguous.20references.3F.html#242045096">(Jun 09 2021 at 10:37)</a>:</h4>
<p>maybe <code>cargo update</code> could run <code>check</code> before and after and abort if it regresses and suggest adding <code>--fix</code>?</p>



<a name="242045437"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Auto-updating%20ambiguous%20references%3F/near/242045437" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Auto-updating.20ambiguous.20references.3F.html#242045437">(Jun 09 2021 at 10:41)</a>:</h4>
<p>I don't know exactly how dependabot is implemented, but if it uses <code>cargo update</code> that would allow RCE on dependabot if it starts doing a <code>cargo check</code>. In any case it is just surprising if <code>cargo update</code> tries to compile your code.</p>



<a name="242083525"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Auto-updating%20ambiguous%20references%3F/near/242083525" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Auto-updating.20ambiguous.20references.3F.html#242083525">(Jun 09 2021 at 15:26)</a>:</h4>
<p>But isn't the point of check that it does not compile the code?</p>
<p>or, are you saying that it could run <a href="http://build.rs">build.rs</a> or something?</p>



<a name="242083666"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Auto-updating%20ambiguous%20references%3F/near/242083666" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Auto-updating.20ambiguous.20references.3F.html#242083666">(Jun 09 2021 at 15:27)</a>:</h4>
<p><code>check</code> does compile and run build scripts and proc macros</p>



<a name="242092264"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Auto-updating%20ambiguous%20references%3F/near/242092264" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Teddy Katz <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Auto-updating.20ambiguous.20references.3F.html#242092264">(Jun 09 2021 at 16:20)</a>:</h4>
<p>I don't have any strong opinions about whether this would be default behavior vs adding flags, was just wondering if anyone has thought about the idea/if it's architecturally feasible.</p>



<a name="242092783"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Auto-updating%20ambiguous%20references%3F/near/242092783" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Auto-updating.20ambiguous.20references.3F.html#242092783">(Jun 09 2021 at 16:24)</a>:</h4>
<p>I recall some discussion about this in the context of rust-analyzer (for some reason)</p>



<a name="242092825"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Auto-updating%20ambiguous%20references%3F/near/242092825" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Auto-updating.20ambiguous.20references.3F.html#242092825">(Jun 09 2021 at 16:24)</a>:</h4>
<p>specifically about machine-applicable migration instructions between versions</p>



<a name="242092897"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Auto-updating%20ambiguous%20references%3F/near/242092897" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Auto-updating.20ambiguous.20references.3F.html#242092897">(Jun 09 2021 at 16:25)</a>:</h4>
<p>ah, it involved rust-analyzer because of its structural-search-replace feature</p>



<a name="242093784"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Auto-updating%20ambiguous%20references%3F/near/242093784" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Teddy Katz <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Auto-updating.20ambiguous.20references.3F.html#242093784">(Jun 09 2021 at 16:31)</a>:</h4>
<p>E.g. I'm not sure whether "converting a method call with one version of a crate to UFCS with another version of a crate" is well-defined, although there is probably an intuitive meaning most of the time. In the general case, if <code>x.foo()</code> resolves to <code>A::foo(x)</code> prior to an upgrade and is ambiguous between <code>A::foo(x)</code> and <code>B::foo(x)</code> afterwards, it still might not be sound to autoreplace it with <code>A::foo(x)</code> if we allow the upgrade to make arbitrary structural changes to the definitions of <code>A</code> and <code>B</code>.</p>



<a name="242093997"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Auto-updating%20ambiguous%20references%3F/near/242093997" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Teddy Katz <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Auto-updating.20ambiguous.20references.3F.html#242093997">(Jun 09 2021 at 16:32)</a>:</h4>
<p>It might require constraining the problem somewhat, e.g. "assume the old and new crate versions are semver-compatible with the exception of name resolution ambiguity"</p>



<a name="242094118"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Auto-updating%20ambiguous%20references%3F/near/242094118" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Teddy Katz <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Auto-updating.20ambiguous.20references.3F.html#242094118">(Jun 09 2021 at 16:33)</a>:</h4>
<p>Even so, it seems like it would nice for mostly-unmaintained projects to be able to upgrade their dependencies reliably without making manual changes to their code.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>